package gui;

import java.util.Vector;

import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

public class UseCaseTableModel extends DefaultTableModel implements java.io.Serializable, TableModelListener{

    UseCaseGUI outer;

    public UseCaseTableModel(Object[][] stuff, String[] otherStuff, UseCaseGUI outer) {
        super(stuff, otherStuff);
        this.outer = outer;
    }
    public UseCaseTableModel(Vector stuff, Vector names, UseCaseGUI outer) {
        super(stuff, names);
        this.outer = outer;
    }

    @Override
    public Class getColumnClass(int c) {
    	Object value = getValueAt(0, c);
    	if( value != null ) {
    		return value.getClass();
    	}
    	return null;
    }
    public TableModel getModel() {
        return this.getModel();
    }

    @Override
    public void tableChanged(TableModelEvent e) {
        int row = e.getFirstRow();
        int column = e.getColumn();
        System.out.print("changing model");
        TableModel model = (TableModel)e.getSource();
        String columnName = model.getColumnName(column);
        Object data = model.getValueAt(row, column);
        //outer.getUCTable().setValueAt(data, row, column);
        System.out.print("model changed");
    }
}
